<%@ page import="com.po.User" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    HttpSession session1 = request.getSession(false);
    List<User> friends = null;
    if (session1 == null || session1.getAttribute("id") == null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp");
    } else {
        friends = (List<User>) request.getAttribute("friends");
    }
%>
<title>好友列表</title>
<h1 style="text-align: center">好友列表</h1>
<table>
    <tr>
        <td><h2>姓名</h2></td>
        <td><h2>成为好友的天数</h2></td>
    </tr>
    <%
        if (friends.isEmpty()) {
            out.println("您暂时还没有好友，请去添加好友");
        } else {
            for (User user : friends) {
    %>
    <tr>
        <td><%=user.getName()%> <%=user.getSex()%>
        </td>
        <td><%=user.getTime()%>天
        </td>
        <td><button onclick="window.location.href='<%=request.getContextPath()%>/chatFriends?user_id=<%=user.getId()%>'">发起聊天</button></td>
    </tr>
<%
        }
    }
%>
</table>
<style>
    table {
        width: 400px;
        margin: auto;
        border: pink 1px solid;
        border-spacing: 0px;
        border-collapse: collapse;
    }

    td {
        border: pink 1px solid;
    }
</style>
<style type="text/css">
    body{
        background-image: url("../picture/new.jpg");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center center;
        background-size: 100% 100%;
    }
</style>
<a href="<%=request.getContextPath()%>/success.jsp">返回功能列表</a>